package cn.bugstack.mybatis.transaction;

import java.sql.Connection;

import javax.sql.DataSource;

import cn.bugstack.mybatis.session.TransactionIsolationLevel;

/**
 * description: 事物工厂
 * taskId：
 * <pre>
 * change history:
 * date             defect#             person                comments
 * ---------------------------------------------------------------------
 * 2024/11/27       ********         zhaochaoyue        create file
 * </pre>
 *
 * @author: zhaochaoyue
 * @date: 2024/11/27 14:54
 * @copyright: 2024
 */
public interface TransactionFactory {

    /**
     * 根据 connection 创建事物
     * @param connection
     * @return
     */
    Transaction newTransaction(Connection connection);

    /**
     * 根据数据源和事物隔离级别创建事物
     * @param dataSource
     * @param transactionIsolationLevel
     * @param autoCommit
     * @return
     */
    Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel transactionIsolationLevel,boolean autoCommit);
}
